﻿using System;
using Microsoft.Xna.Framework;
using Terraria.GameContent;
using Terraria.GameContent.Events;
using Terraria.Graphics.Shaders;
using Terraria.ModLoader;
using Terraria.Utilities;

namespace Terraria
{
	// Token: 0x0200000D RID: 13
	public class Dust
	{
		// Token: 0x060000B9 RID: 185 RVA: 0x0002BF80 File Offset: 0x0002A180
		public static Dust NewDustPerfect(Vector2 Position, int Type, Vector2? Velocity = null, int Alpha = 0, Color newColor = default(Color), float Scale = 1f)
		{
			Dust dust = Main.dust[Dust.NewDust(Position, 0, 0, Type, 0f, 0f, Alpha, newColor, Scale)];
			dust.position = Position;
			if (Velocity != null)
			{
				dust.velocity = Velocity.Value;
			}
			return dust;
		}

		// Token: 0x060000BA RID: 186 RVA: 0x0002BFCC File Offset: 0x0002A1CC
		public static Dust NewDustDirect(Vector2 Position, int Width, int Height, int Type, float SpeedX = 0f, float SpeedY = 0f, int Alpha = 0, Color newColor = default(Color), float Scale = 1f)
		{
			Dust dust = Main.dust[Dust.NewDust(Position, Width, Height, Type, SpeedX, SpeedY, Alpha, newColor, Scale)];
			if (dust.velocity.HasNaNs())
			{
				dust.velocity = Vector2.Zero;
			}
			return dust;
		}

		// Token: 0x060000BB RID: 187 RVA: 0x0002C00C File Offset: 0x0002A20C
		public static int NewDust(Vector2 Position, int Width, int Height, int Type, float SpeedX = 0f, float SpeedY = 0f, int Alpha = 0, Color newColor = default(Color), float Scale = 1f)
		{
			if (Main.gameMenu)
			{
				return 6000;
			}
			if (Main.rand == null)
			{
				Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
			}
			if (Main.gamePaused)
			{
				return 6000;
			}
			if (WorldGen.gen)
			{
				return 6000;
			}
			if (Main.netMode == 2)
			{
				return 6000;
			}
			int num = (int)(400f * (1f - Dust.dCount));
			Rectangle rectangle = new Rectangle((int)(Main.screenPosition.X - (float)num), (int)(Main.screenPosition.Y - (float)num), Main.screenWidth + num * 2, Main.screenHeight + num * 2);
			Rectangle value = new Rectangle((int)Position.X, (int)Position.Y, 10, 10);
			if (!rectangle.Intersects(value))
			{
				return 6000;
			}
			int result = 6000;
			int i = 0;
			while (i < 6000)
			{
				Dust dust = Main.dust[i];
				if (!dust.active)
				{
					if ((double)i > (double)Main.maxDustToDraw * 0.9)
					{
						if (Main.rand.Next(4) != 0)
						{
							return 5999;
						}
					}
					else if ((double)i > (double)Main.maxDustToDraw * 0.8)
					{
						if (Main.rand.Next(3) != 0)
						{
							return 5999;
						}
					}
					else if ((double)i > (double)Main.maxDustToDraw * 0.7)
					{
						if (Main.rand.Next(2) == 0)
						{
							return 5999;
						}
					}
					else if ((double)i > (double)Main.maxDustToDraw * 0.6)
					{
						if (Main.rand.Next(4) == 0)
						{
							return 5999;
						}
					}
					else if ((double)i > (double)Main.maxDustToDraw * 0.5)
					{
						if (Main.rand.Next(5) == 0)
						{
							return 5999;
						}
					}
					else
					{
						Dust.dCount = 0f;
					}
					int num2 = Width;
					int num3 = Height;
					if (num2 < 5)
					{
						num2 = 5;
					}
					if (num3 < 5)
					{
						num3 = 5;
					}
					result = i;
					dust.fadeIn = 0f;
					dust.active = true;
					dust.type = Type;
					dust.noGravity = false;
					dust.color = newColor;
					dust.alpha = Alpha;
					dust.position.X = Position.X + (float)Main.rand.Next(num2 - 4) + 4f;
					dust.position.Y = Position.Y + (float)Main.rand.Next(num3 - 4) + 4f;
					dust.velocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + SpeedX;
					dust.velocity.Y = (float)Main.rand.Next(-20, 21) * 0.1f + SpeedY;
					dust.frame.X = 10 * Type;
					dust.frame.Y = 10 * Main.rand.Next(3);
					dust.shader = null;
					dust.customData = null;
					int j = Type;
					while (j >= 100)
					{
						j -= 100;
						Dust dust2 = dust;
						dust2.frame.X = dust2.frame.X - 1000;
						Dust dust3 = dust;
						dust3.frame.Y = dust3.frame.Y + 30;
					}
					dust.frame.Width = 8;
					dust.frame.Height = 8;
					dust.rotation = 0f;
					dust.scale = 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
					dust.scale *= Scale;
					dust.noLight = false;
					dust.firstFrame = true;
					if (dust.type == 228 || dust.type == 269 || dust.type == 135 || dust.type == 6 || dust.type == 242 || dust.type == 75 || dust.type == 169 || dust.type == 29 || (dust.type >= 59 && dust.type <= 65) || dust.type == 158)
					{
						dust.velocity.Y = (float)Main.rand.Next(-10, 6) * 0.1f;
						Dust dust4 = dust;
						dust4.velocity.X = dust4.velocity.X * 0.3f;
						dust.scale *= 0.7f;
					}
					if (dust.type == 127 || dust.type == 187)
					{
						dust.velocity *= 0.3f;
						dust.scale *= 0.7f;
					}
					if (dust.type == 33 || dust.type == 52 || dust.type == 266 || dust.type == 98 || dust.type == 99 || dust.type == 100 || dust.type == 101 || dust.type == 102 || dust.type == 103 || dust.type == 104 || dust.type == 105)
					{
						dust.alpha = 170;
						dust.velocity *= 0.5f;
						Dust dust5 = dust;
						dust5.velocity.Y = dust5.velocity.Y + 1f;
					}
					if (dust.type == 41)
					{
						dust.velocity *= 0f;
					}
					if (dust.type == 80)
					{
						dust.alpha = 50;
					}
					ModDust.SetupDust(dust);
					if (dust.type != 34 && dust.type != 35 && dust.type != 152)
					{
						break;
					}
					dust.velocity *= 0.1f;
					dust.velocity.Y = -0.5f;
					if (dust.type == 34 && !Collision.WetCollision(new Vector2(dust.position.X, dust.position.Y - 8f), 4, 4))
					{
						dust.active = false;
						break;
					}
					break;
				}
				else
				{
					i++;
				}
			}
			return result;
		}

		// Token: 0x060000BC RID: 188 RVA: 0x0002C678 File Offset: 0x0002A878
		public static Dust CloneDust(int dustIndex)
		{
			Dust rf = Main.dust[dustIndex];
			return Dust.CloneDust(rf);
		}

		// Token: 0x060000BD RID: 189 RVA: 0x0002C694 File Offset: 0x0002A894
		public static Dust CloneDust(Dust rf)
		{
			if (rf.dustIndex == Main.maxDustToDraw)
			{
				return rf;
			}
			int num = Dust.NewDust(rf.position, 0, 0, rf.type, 0f, 0f, 0, default(Color), 1f);
			Dust dust = Main.dust[num];
			dust.position = rf.position;
			dust.velocity = rf.velocity;
			dust.fadeIn = rf.fadeIn;
			dust.noGravity = rf.noGravity;
			dust.scale = rf.scale;
			dust.rotation = rf.rotation;
			dust.noLight = rf.noLight;
			dust.active = rf.active;
			dust.type = rf.type;
			dust.color = rf.color;
			dust.alpha = rf.alpha;
			dust.frame = rf.frame;
			dust.shader = rf.shader;
			dust.customData = rf.customData;
			return dust;
		}

		// Token: 0x060000BE RID: 190 RVA: 0x000066E2 File Offset: 0x000048E2
		public static Dust QuickDust(Point tileCoords, Color color)
		{
			return Dust.QuickDust(tileCoords.ToWorldCoordinates(8f, 8f), color);
		}

		// Token: 0x060000BF RID: 191 RVA: 0x0002C790 File Offset: 0x0002A990
		public static void QuickBox(Vector2 topLeft, Vector2 bottomRight, int divisions, Color color, Action<Dust> manipulator)
		{
			float num = (float)(divisions + 2);
			for (float num2 = 0f; num2 <= (float)(divisions + 2); num2 += 1f)
			{
				Dust obj = Dust.QuickDust(new Vector2(MathHelper.Lerp(topLeft.X, bottomRight.X, num2 / num), topLeft.Y), color);
				if (manipulator != null)
				{
					manipulator(obj);
				}
				obj = Dust.QuickDust(new Vector2(MathHelper.Lerp(topLeft.X, bottomRight.X, num2 / num), bottomRight.Y), color);
				if (manipulator != null)
				{
					manipulator(obj);
				}
				obj = Dust.QuickDust(new Vector2(topLeft.X, MathHelper.Lerp(topLeft.Y, bottomRight.Y, num2 / num)), color);
				if (manipulator != null)
				{
					manipulator(obj);
				}
				obj = Dust.QuickDust(new Vector2(bottomRight.X, MathHelper.Lerp(topLeft.Y, bottomRight.Y, num2 / num)), color);
				if (manipulator != null)
				{
					manipulator(obj);
				}
			}
		}

		// Token: 0x060000C0 RID: 192 RVA: 0x0002C888 File Offset: 0x0002AA88
		public static Dust QuickDust(Vector2 pos, Color color)
		{
			Dust dust = Main.dust[Dust.NewDust(pos, 0, 0, 267, 0f, 0f, 0, default(Color), 1f)];
			dust.position = pos;
			dust.velocity = Vector2.Zero;
			dust.fadeIn = 1f;
			dust.noLight = true;
			dust.noGravity = true;
			dust.color = color;
			return dust;
		}

		// Token: 0x060000C1 RID: 193 RVA: 0x0002C8F8 File Offset: 0x0002AAF8
		public static void QuickDustLine(Vector2 start, Vector2 end, float splits, Color color)
		{
			Dust.QuickDust(start, color).scale = 2f;
			Dust.QuickDust(end, color).scale = 2f;
			float num = 1f / splits;
			for (float num2 = 0f; num2 < 1f; num2 += num)
			{
				Dust.QuickDust(Vector2.Lerp(start, end, num2), color).scale = 2f;
			}
		}

		// Token: 0x060000C2 RID: 194 RVA: 0x0002C95C File Offset: 0x0002AB5C
		public static int dustWater()
		{
			if (Main.waterStyle >= 12)
			{
				return WaterStyleLoader.GetWaterStyle(Main.waterStyle).GetSplashDust();
			}
			switch (Main.waterStyle)
			{
			case 2:
				return 98;
			case 3:
				return 99;
			case 4:
				return 100;
			case 5:
				return 101;
			case 6:
				return 102;
			case 7:
				return 103;
			case 8:
				return 104;
			case 9:
				return 105;
			case 10:
				return 123;
			default:
				return 33;
			}
		}

		// Token: 0x060000C3 RID: 195 RVA: 0x0002C9D4 File Offset: 0x0002ABD4
		public static void UpdateDust()
		{
			int num = 0;
			Dust.lavaBubbles = 0;
			Main.snowDust = 0;
			Dust.SandStormCount = 0;
			bool flag = Sandstorm.Happening && Main.player[Main.myPlayer].ZoneSandstorm && (Main.bgStyle == 2 || Main.bgStyle == 5) && Main.bgDelay < 50;
			int num3;
			for (int i = 0; i < 6000; i = num3 + 1)
			{
				Dust dust = Main.dust[i];
				if (i < Main.maxDustToDraw)
				{
					if (dust.active)
					{
						Dust.dCount += 1f;
						ModDust.SetupUpdateType(dust);
						ModDust dust2 = ModDust.GetDust(dust.type);
						if (dust2 != null && !dust2.Update(dust))
						{
							ModDust.TakeDownUpdateType(dust);
						}
						else
						{
							if (dust.scale > 10f)
							{
								dust.active = false;
							}
							if (dust.firstFrame && !ChildSafety.Disabled && ChildSafety.DangerousDust(dust.type))
							{
								if (Main.rand.Next(2) == 0)
								{
									dust.firstFrame = false;
									dust.type = 16;
									dust.scale = Main.rand.NextFloat() * 1.6f + 0.3f;
									dust.color = Color.Transparent;
									dust.frame.X = 10 * dust.type;
									dust.frame.Y = 10 * Main.rand.Next(3);
									dust.shader = null;
									dust.customData = null;
									int num2 = dust.type / 100;
									Dust dust3 = dust;
									dust3.frame.X = dust3.frame.X - 1000 * num2;
									Dust dust4 = dust;
									dust4.frame.Y = dust4.frame.Y + 30 * num2;
									dust.noGravity = true;
								}
								else
								{
									dust.active = false;
								}
							}
							if (dust.type == 35)
							{
								num3 = Dust.lavaBubbles;
								Dust.lavaBubbles = num3 + 1;
							}
							Dust dust5 = dust;
							dust5.position += dust.velocity;
							if (dust.type == 258)
							{
								dust.noGravity = true;
								dust5 = dust;
								dust5.scale += 0.015f;
							}
							if (dust.type >= 86 && dust.type <= 92 && !dust.noLight)
							{
								float num4 = dust.scale * 0.6f;
								if (num4 > 1f)
								{
									num4 = 1f;
								}
								int num5 = dust.type - 85;
								float num6 = num4;
								float num7 = num4;
								float num8 = num4;
								if (num5 == 3)
								{
									num6 *= 0f;
									num7 *= 0.1f;
									num8 *= 1.3f;
								}
								else if (num5 == 5)
								{
									num6 *= 1f;
									num7 *= 0.1f;
									num8 *= 0.1f;
								}
								else if (num5 == 4)
								{
									num6 *= 0f;
									num7 *= 1f;
									num8 *= 0.1f;
								}
								else if (num5 == 1)
								{
									num6 *= 0.9f;
									num7 *= 0f;
									num8 *= 0.9f;
								}
								else if (num5 == 6)
								{
									num6 *= 1.3f;
									num7 *= 1.3f;
									num8 *= 1.3f;
								}
								else if (num5 == 2)
								{
									num6 *= 0.9f;
									num7 *= 0.9f;
									num8 *= 0f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num4 * num6, num4 * num7, num4 * num8);
							}
							if (dust.type >= 86 && dust.type <= 92)
							{
								if (dust.customData != null && dust.customData is Player)
								{
									Player player = (Player)dust.customData;
									dust5 = dust;
									dust5.position += player.position - player.oldPosition;
								}
								else if (dust.customData != null && dust.customData is Projectile)
								{
									Projectile projectile = (Projectile)dust.customData;
									if (projectile.active)
									{
										dust5 = dust;
										dust5.position += projectile.position - projectile.oldPosition;
									}
								}
							}
							if (dust.type == 262 && !dust.noLight)
							{
								Vector3 rgb = new Vector3(0.9f, 0.6f, 0f) * dust.scale * 0.6f;
								Lighting.AddLight(dust.position, rgb);
							}
							if (dust.type == 240 && dust.customData != null && dust.customData is Projectile)
							{
								Projectile projectile2 = (Projectile)dust.customData;
								if (projectile2.active)
								{
									dust5 = dust;
									dust5.position += projectile2.position - projectile2.oldPosition;
								}
							}
							if ((dust.type == 259 || dust.type == 6 || dust.type == 158) && dust.customData != null && dust.customData is int)
							{
								if ((int)dust.customData == 0)
								{
									if (Collision.SolidCollision(dust.position - Vector2.One * 5f, 10, 10) && dust.fadeIn == 0f)
									{
										dust5 = dust;
										dust5.scale *= 0.9f;
										dust5 = dust;
										dust5.velocity *= 0.25f;
									}
								}
								else if ((int)dust.customData == 1)
								{
									dust5 = dust;
									dust5.scale *= 0.98f;
									Dust dust6 = dust;
									dust6.velocity.Y = dust6.velocity.Y * 0.98f;
									if (Collision.SolidCollision(dust.position - Vector2.One * 5f, 10, 10) && dust.fadeIn == 0f)
									{
										dust5 = dust;
										dust5.scale *= 0.9f;
										dust5 = dust;
										dust5.velocity *= 0.25f;
									}
								}
							}
							if (dust.type == 263 || dust.type == 264)
							{
								if (!dust.noLight)
								{
									Vector3 rgb2 = dust.color.ToVector3() * dust.scale * 0.4f;
									Lighting.AddLight(dust.position, rgb2);
								}
								if (dust.customData != null && dust.customData is Player)
								{
									Player player2 = (Player)dust.customData;
									dust5 = dust;
									dust5.position += player2.position - player2.oldPosition;
									dust.customData = null;
								}
								else if (dust.customData != null && dust.customData is Projectile)
								{
									Projectile projectile3 = (Projectile)dust.customData;
									dust5 = dust;
									dust5.position += projectile3.position - projectile3.oldPosition;
								}
							}
							if (dust.type == 230)
							{
								float num9 = dust.scale * 0.6f;
								float num10 = num9;
								float num11 = num9;
								float num12 = num9;
								num10 *= 0.5f;
								num11 *= 0.9f;
								num12 *= 1f;
								dust5 = dust;
								dust5.scale += 0.02f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num9 * num10, num9 * num11, num9 * num12);
								if (dust.customData != null && dust.customData is Player)
								{
									Vector2 center = ((Player)dust.customData).Center;
									Vector2 value = dust.position;
									Vector2 vector = value - center;
									float num13 = vector.Length();
									vector /= num13;
									dust.scale = Math.Min(dust.scale, num13 / 24f - 1f);
									dust5 = dust;
									dust5.velocity -= vector * (100f / Math.Max(50f, num13));
								}
							}
							if (dust.type == 154 || dust.type == 218)
							{
								dust5 = dust;
								dust5.rotation += dust.velocity.X * 0.3f;
								dust5 = dust;
								dust5.scale -= 0.03f;
							}
							if (dust.type == 172)
							{
								float num14 = dust.scale * 0.5f;
								if (num14 > 1f)
								{
									num14 = 1f;
								}
								float num15 = num14;
								float num16 = num14;
								float num17 = num14;
								num15 *= 0f;
								num16 *= 0.25f;
								num17 *= 1f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num14 * num15, num14 * num16, num14 * num17);
							}
							if (dust.type == 182)
							{
								dust5 = dust;
								dust5.rotation += 1f;
								if (!dust.noLight)
								{
									float num18 = dust.scale * 0.25f;
									if (num18 > 1f)
									{
										num18 = 1f;
									}
									float num19 = num18;
									float num20 = num18;
									float num21 = num18;
									num19 *= 1f;
									num20 *= 0.2f;
									num21 *= 0.1f;
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num18 * num19, num18 * num20, num18 * num21);
								}
								if (dust.customData != null && dust.customData is Player)
								{
									Player player3 = (Player)dust.customData;
									dust5 = dust;
									dust5.position += player3.position - player3.oldPosition;
									dust.customData = null;
								}
							}
							if (dust.type == 261)
							{
								if (!dust.noLight)
								{
									float num22 = dust.scale * 0.3f;
									if (num22 > 1f)
									{
										num22 = 1f;
									}
									Lighting.AddLight(dust.position, new Vector3(0.4f, 0.6f, 0.7f) * num22);
								}
								if (dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0.93f;
									if (dust.fadeIn == 0f)
									{
										dust5 = dust;
										dust5.scale += 0.0025f;
									}
								}
								dust5 = dust;
								dust5.velocity *= new Vector2(0.97f, 0.99f);
								dust5 = dust;
								dust5.scale -= 0.0025f;
								if (dust.customData != null && dust.customData is Player)
								{
									Player player4 = (Player)dust.customData;
									dust5 = dust;
									dust5.position += player4.position - player4.oldPosition;
								}
							}
							if (dust.type == 254)
							{
								float num23 = dust.scale * 0.35f;
								if (num23 > 1f)
								{
									num23 = 1f;
								}
								float num24 = num23;
								float num25 = num23;
								float num26 = num23;
								num24 *= 0.9f;
								num25 *= 0.1f;
								num26 *= 0.75f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num23 * num24, num23 * num25, num23 * num26);
							}
							if (dust.type == 255)
							{
								float num27 = dust.scale * 0.25f;
								if (num27 > 1f)
								{
									num27 = 1f;
								}
								float num28 = num27;
								float num29 = num27;
								float num30 = num27;
								num28 *= 0.9f;
								num29 *= 0.1f;
								num30 *= 0.75f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num27 * num28, num27 * num29, num27 * num30);
							}
							if (dust.type == 211 && dust.noLight && Collision.SolidCollision(dust.position, 4, 4))
							{
								dust.active = false;
							}
							if (dust.type == 213 || dust.type == 260)
							{
								dust.rotation = 0f;
								float num31 = dust.scale / 2.5f * 0.2f;
								Vector3 vector2 = Vector3.Zero;
								int num32 = dust.type;
								if (num32 != 213)
								{
									if (num32 == 260)
									{
										vector2 = new Vector3(255f, 48f, 48f);
									}
								}
								else
								{
									vector2 = new Vector3(255f, 217f, 48f);
								}
								vector2 /= 255f;
								if (num31 > 1f)
								{
									num31 = 1f;
								}
								vector2 *= num31;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), vector2.X, vector2.Y, vector2.Z);
							}
							if (dust.type == 157)
							{
								float num33 = dust.scale * 0.2f;
								float num34 = num33;
								float num35 = num33;
								float num36 = num33;
								num34 *= 0.25f;
								num35 *= 1f;
								num36 *= 0.5f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num33 * num34, num33 * num35, num33 * num36);
							}
							if (dust.type == 206)
							{
								dust5 = dust;
								dust5.scale -= 0.1f;
								float num37 = dust.scale * 0.4f;
								float num38 = num37;
								float num39 = num37;
								float num40 = num37;
								num38 *= 0.1f;
								num39 *= 0.6f;
								num40 *= 1f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num37 * num38, num37 * num39, num37 * num40);
							}
							if (dust.type == 163)
							{
								float num41 = dust.scale * 0.25f;
								float num42 = num41;
								float num43 = num41;
								float num44 = num41;
								num42 *= 0.25f;
								num43 *= 1f;
								num44 *= 0.05f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num41 * num42, num41 * num43, num41 * num44);
							}
							if (dust.type == 205)
							{
								float num45 = dust.scale * 0.25f;
								float num46 = num45;
								float num47 = num45;
								float num48 = num45;
								num46 *= 1f;
								num47 *= 0.05f;
								num48 *= 1f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num45 * num46, num45 * num47, num45 * num48);
							}
							if (dust.type == 170)
							{
								float num49 = dust.scale * 0.5f;
								float num50 = num49;
								float num51 = num49;
								float num52 = num49;
								num50 *= 1f;
								num51 *= 1f;
								num52 *= 0.05f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num49 * num50, num49 * num51, num49 * num52);
							}
							if (dust.type == 156)
							{
								float num53 = dust.scale * 0.6f;
								int num54 = dust.type;
								float num55 = num53;
								float num56 = num53;
								float num57 = num53;
								num55 *= 0.5f;
								num56 *= 0.9f;
								num57 *= 1f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num53 * num55, num53 * num56, num53 * num57);
							}
							if (dust.type == 234)
							{
								float num58 = dust.scale * 0.6f;
								int num59 = dust.type;
								float num60 = num58;
								float num61 = num58;
								float num62 = num58;
								num60 *= 0.95f;
								num61 *= 0.65f;
								num62 *= 1.3f;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num58 * num60, num58 * num61, num58 * num62);
							}
							if (dust.type == 175)
							{
								dust5 = dust;
								dust5.scale -= 0.05f;
							}
							if (dust.type == 174)
							{
								dust5 = dust;
								dust5.scale -= 0.01f;
								float num63 = dust.scale * 1f;
								if (num63 > 0.6f)
								{
									num63 = 0.6f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num63, num63 * 0.4f, 0f);
							}
							if (dust.type == 235)
							{
								Vector2 value2 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
								value2.Normalize();
								value2 *= 15f;
								dust5 = dust;
								dust5.scale -= 0.01f;
							}
							else if (dust.type == 228 || dust.type == 229 || dust.type == 6 || dust.type == 242 || dust.type == 135 || dust.type == 127 || dust.type == 187 || dust.type == 75 || dust.type == 169 || dust.type == 29 || (dust.type >= 59 && dust.type <= 65) || dust.type == 158)
							{
								if (!dust.noGravity)
								{
									Dust dust7 = dust;
									dust7.velocity.Y = dust7.velocity.Y + 0.05f;
								}
								if (dust.type == 229 || dust.type == 228)
								{
									if (dust.customData != null && dust.customData is NPC)
									{
										NPC npc = (NPC)dust.customData;
										dust5 = dust;
										dust5.position += npc.position - npc.oldPos[1];
									}
									else if (dust.customData != null && dust.customData is Player)
									{
										Player player5 = (Player)dust.customData;
										dust5 = dust;
										dust5.position += player5.position - player5.oldPosition;
									}
									else if (dust.customData != null && dust.customData is Vector2)
									{
										Vector2 vector3 = (Vector2)dust.customData - dust.position;
										if (vector3 != Vector2.Zero)
										{
											vector3.Normalize();
										}
										dust.velocity = (dust.velocity * 4f + vector3 * dust.velocity.Length()) / 5f;
									}
								}
								if (!dust.noLight)
								{
									float num64 = dust.scale * 1.4f;
									if (dust.type == 29)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 0.1f, num64 * 0.4f, num64);
									}
									else if (dust.type == 75)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 0.7f, num64, num64 * 0.2f);
									}
									else if (dust.type == 169)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 1.1f, num64 * 1.1f, num64 * 0.2f);
									}
									else if (dust.type == 135)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 0.2f, num64 * 0.7f, num64);
									}
									else if (dust.type == 158)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 1f, num64 * 0.5f, 0f);
									}
									else if (dust.type == 228)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 0.7f, num64 * 0.65f, num64 * 0.3f);
									}
									else if (dust.type == 229)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 0.3f, num64 * 0.65f, num64 * 0.7f);
									}
									else if (dust.type == 242)
									{
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64, 0f, num64);
									}
									else if (dust.type >= 59 && dust.type <= 65)
									{
										if (num64 > 0.8f)
										{
											num64 = 0.8f;
										}
										int num65 = dust.type - 58;
										float num66 = 1f;
										float num67 = 1f;
										float num68 = 1f;
										if (num65 == 1)
										{
											num66 = 0f;
											num67 = 0.1f;
											num68 = 1.3f;
										}
										else if (num65 == 2)
										{
											num66 = 1f;
											num67 = 0.1f;
											num68 = 0.1f;
										}
										else if (num65 == 3)
										{
											num66 = 0f;
											num67 = 1f;
											num68 = 0.1f;
										}
										else if (num65 == 4)
										{
											num66 = 0.9f;
											num67 = 0f;
											num68 = 0.9f;
										}
										else if (num65 == 5)
										{
											num66 = 1.3f;
											num67 = 1.3f;
											num68 = 1.3f;
										}
										else if (num65 == 6)
										{
											num66 = 0.9f;
											num67 = 0.9f;
											num68 = 0f;
										}
										else if (num65 == 7)
										{
											num66 = 0.5f * Main.demonTorch + 1f * (1f - Main.demonTorch);
											num67 = 0.3f;
											num68 = 1f * Main.demonTorch + 0.5f * (1f - Main.demonTorch);
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * num66, num64 * num67, num64 * num68);
									}
									else if (dust.type == 127)
									{
										num64 *= 1.3f;
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64, num64 * 0.45f, num64 * 0.2f);
									}
									else if (dust.type == 187)
									{
										num64 *= 1.3f;
										if (num64 > 1f)
										{
											num64 = 1f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64 * 0.2f, num64 * 0.45f, num64);
									}
									else
									{
										if (num64 > 0.6f)
										{
											num64 = 0.6f;
										}
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num64, num64 * 0.65f, num64 * 0.4f);
									}
								}
							}
							else if (dust.type == 269)
							{
								if (!dust.noLight)
								{
									float num69 = dust.scale * 1.4f;
									if (num69 > 1f)
									{
										num69 = 1f;
									}
									Vector3 value3 = new Vector3(0.7f, 0.65f, 0.3f);
									Lighting.AddLight(dust.position, value3 * num69);
								}
								if (dust.customData != null && dust.customData is Vector2)
								{
									Vector2 vector4 = (Vector2)dust.customData - dust.position;
									Dust dust8 = dust;
									dust8.velocity.X = dust8.velocity.X + 1f * (float)Math.Sign(vector4.X) * dust.scale;
								}
							}
							else if (dust.type == 159)
							{
								float num70 = dust.scale * 1.3f;
								if (num70 > 1f)
								{
									num70 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num70, num70, num70 * 0.1f);
								if (dust.noGravity)
								{
									if (dust.scale < 0.7f)
									{
										dust5 = dust;
										dust5.velocity *= 1.075f;
									}
									else if (Main.rand.Next(2) == 0)
									{
										dust5 = dust;
										dust5.velocity *= -0.95f;
									}
									else
									{
										dust5 = dust;
										dust5.velocity *= 1.05f;
									}
									dust5 = dust;
									dust5.scale -= 0.03f;
								}
								else
								{
									dust5 = dust;
									dust5.scale += 0.005f;
									dust5 = dust;
									dust5.velocity *= 0.9f;
									Dust dust9 = dust;
									dust9.velocity.X = dust9.velocity.X + (float)Main.rand.Next(-10, 11) * 0.02f;
									Dust dust10 = dust;
									dust10.velocity.Y = dust10.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.02f;
									if (Main.rand.Next(5) == 0)
									{
										int num71 = Dust.NewDust(dust.position, 4, 4, dust.type, 0f, 0f, 0, default(Color), 1f);
										Main.dust[num71].noGravity = true;
										Main.dust[num71].scale = dust.scale * 2.5f;
									}
								}
							}
							else if (dust.type == 164)
							{
								float num72 = dust.scale;
								if (num72 > 1f)
								{
									num72 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num72, num72 * 0.1f, num72 * 0.8f);
								if (dust.noGravity)
								{
									if (dust.scale < 0.7f)
									{
										dust5 = dust;
										dust5.velocity *= 1.075f;
									}
									else if (Main.rand.Next(2) == 0)
									{
										dust5 = dust;
										dust5.velocity *= -0.95f;
									}
									else
									{
										dust5 = dust;
										dust5.velocity *= 1.05f;
									}
									dust5 = dust;
									dust5.scale -= 0.03f;
								}
								else
								{
									dust5 = dust;
									dust5.scale -= 0.005f;
									dust5 = dust;
									dust5.velocity *= 0.9f;
									Dust dust11 = dust;
									dust11.velocity.X = dust11.velocity.X + (float)Main.rand.Next(-10, 11) * 0.02f;
									Dust dust12 = dust;
									dust12.velocity.Y = dust12.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.02f;
									if (Main.rand.Next(5) == 0)
									{
										int num73 = Dust.NewDust(dust.position, 4, 4, dust.type, 0f, 0f, 0, default(Color), 1f);
										Main.dust[num73].noGravity = true;
										Main.dust[num73].scale = dust.scale * 2.5f;
									}
								}
							}
							else if (dust.type == 173)
							{
								float num74 = dust.scale;
								if (num74 > 1f)
								{
									num74 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num74 * 0.4f, num74 * 0.1f, num74);
								if (dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0.8f;
									Dust dust13 = dust;
									dust13.velocity.X = dust13.velocity.X + (float)Main.rand.Next(-20, 21) * 0.01f;
									Dust dust14 = dust;
									dust14.velocity.Y = dust14.velocity.Y + (float)Main.rand.Next(-20, 21) * 0.01f;
									dust5 = dust;
									dust5.scale -= 0.01f;
								}
								else
								{
									dust5 = dust;
									dust5.scale -= 0.015f;
									dust5 = dust;
									dust5.velocity *= 0.8f;
									Dust dust15 = dust;
									dust15.velocity.X = dust15.velocity.X + (float)Main.rand.Next(-10, 11) * 0.005f;
									Dust dust16 = dust;
									dust16.velocity.Y = dust16.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.005f;
									if (Main.rand.Next(10) == 10)
									{
										int num75 = Dust.NewDust(dust.position, 4, 4, dust.type, 0f, 0f, 0, default(Color), 1f);
										Main.dust[num75].noGravity = true;
										Main.dust[num75].scale = dust.scale;
									}
								}
							}
							else if (dust.type == 184)
							{
								if (!dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0f;
									dust5 = dust;
									dust5.scale -= 0.01f;
								}
							}
							else if (dust.type == 160 || dust.type == 162)
							{
								float num76 = dust.scale * 1.3f;
								if (num76 > 1f)
								{
									num76 = 1f;
								}
								if (dust.type == 162)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num76, num76 * 0.7f, num76 * 0.1f);
								}
								else
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num76 * 0.1f, num76, num76);
								}
								if (dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0.8f;
									Dust dust17 = dust;
									dust17.velocity.X = dust17.velocity.X + (float)Main.rand.Next(-20, 21) * 0.04f;
									Dust dust18 = dust;
									dust18.velocity.Y = dust18.velocity.Y + (float)Main.rand.Next(-20, 21) * 0.04f;
									dust5 = dust;
									dust5.scale -= 0.1f;
								}
								else
								{
									dust5 = dust;
									dust5.scale -= 0.1f;
									Dust dust19 = dust;
									dust19.velocity.X = dust19.velocity.X + (float)Main.rand.Next(-10, 11) * 0.02f;
									Dust dust20 = dust;
									dust20.velocity.Y = dust20.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.02f;
									if ((double)dust.scale > 0.3 && Main.rand.Next(50) == 0)
									{
										int num77 = Dust.NewDust(new Vector2(dust.position.X - 4f, dust.position.Y - 4f), 1, 1, dust.type, 0f, 0f, 0, default(Color), 1f);
										Main.dust[num77].noGravity = true;
										Main.dust[num77].scale = dust.scale * 1.5f;
									}
								}
							}
							else if (dust.type == 168)
							{
								float num78 = dust.scale * 0.8f;
								if ((double)num78 > 0.55)
								{
									num78 = 0.55f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num78, 0f, num78 * 0.8f);
								dust5 = dust;
								dust5.scale += 0.03f;
								Dust dust21 = dust;
								dust21.velocity.X = dust21.velocity.X + (float)Main.rand.Next(-10, 11) * 0.02f;
								Dust dust22 = dust;
								dust22.velocity.Y = dust22.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.02f;
								dust5 = dust;
								dust5.velocity *= 0.99f;
							}
							else if (dust.type >= 139 && dust.type < 143)
							{
								Dust dust23 = dust;
								dust23.velocity.X = dust23.velocity.X * 0.98f;
								Dust dust24 = dust;
								dust24.velocity.Y = dust24.velocity.Y * 0.98f;
								if (dust.velocity.Y < 1f)
								{
									Dust dust25 = dust;
									dust25.velocity.Y = dust25.velocity.Y + 0.05f;
								}
								dust5 = dust;
								dust5.scale += 0.009f;
								dust5 = dust;
								dust5.rotation -= dust.velocity.X * 0.4f;
								if (dust.velocity.X > 0f)
								{
									dust5 = dust;
									dust5.rotation += 0.005f;
								}
								else
								{
									dust5 = dust;
									dust5.rotation -= 0.005f;
								}
							}
							else if (dust.type == 14 || dust.type == 16 || dust.type == 31 || dust.type == 46 || dust.type == 124 || dust.type == 186 || dust.type == 188)
							{
								Dust dust26 = dust;
								dust26.velocity.Y = dust26.velocity.Y * 0.98f;
								Dust dust27 = dust;
								dust27.velocity.X = dust27.velocity.X * 0.98f;
								if (dust.type == 31 && dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 1.02f;
									dust5 = dust;
									dust5.scale += 0.02f;
									dust5 = dust;
									dust5.alpha += 4;
									if (dust.alpha > 255)
									{
										dust.scale = 0.0001f;
										dust.alpha = 255;
									}
								}
							}
							else if (dust.type == 32)
							{
								dust5 = dust;
								dust5.scale -= 0.01f;
								Dust dust28 = dust;
								dust28.velocity.X = dust28.velocity.X * 0.96f;
								if (!dust.noGravity)
								{
									Dust dust29 = dust;
									dust29.velocity.Y = dust29.velocity.Y + 0.1f;
								}
							}
							else if (dust.type >= 244 && dust.type <= 247)
							{
								dust5 = dust;
								dust5.rotation += 0.1f * dust.scale;
								Color color = Lighting.GetColor((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f));
								byte b = (color.R + color.G + color.B) / 3;
								float num79 = ((float)b / 270f + 1f) / 2f;
								float num80 = ((float)b / 270f + 1f) / 2f;
								float num81 = ((float)b / 270f + 1f) / 2f;
								num79 *= dust.scale * 0.9f;
								num80 *= dust.scale * 0.9f;
								num81 *= dust.scale * 0.9f;
								if (dust.alpha < 255)
								{
									dust5 = dust;
									dust5.scale += 0.09f;
									if (dust.scale >= 1f)
									{
										dust.scale = 1f;
										dust.alpha = 255;
									}
								}
								else
								{
									if ((double)dust.scale < 0.8)
									{
										dust5 = dust;
										dust5.scale -= 0.01f;
									}
									if ((double)dust.scale < 0.5)
									{
										dust5 = dust;
										dust5.scale -= 0.01f;
									}
								}
								float num82 = 1f;
								if (dust.type == 244)
								{
									num79 *= 0.8862745f;
									num80 *= 0.4627451f;
									num81 *= 0.298039228f;
									num82 = 0.9f;
								}
								else if (dust.type == 245)
								{
									num79 *= 0.5137255f;
									num80 *= 0.6745098f;
									num81 *= 0.6784314f;
									num82 = 1f;
								}
								else if (dust.type == 246)
								{
									num79 *= 0.8f;
									num80 *= 0.709803939f;
									num81 *= 0.282352954f;
									num82 = 1.1f;
								}
								else if (dust.type == 247)
								{
									num79 *= 0.6f;
									num80 *= 0.6745098f;
									num81 *= 0.7254902f;
									num82 = 1.2f;
								}
								num79 *= num82;
								num80 *= num82;
								num81 *= num82;
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num79, num80, num81);
							}
							else if (dust.type == 43)
							{
								dust5 = dust;
								dust5.rotation += 0.1f * dust.scale;
								Color color2 = Lighting.GetColor((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f));
								float num83 = (float)color2.R / 270f;
								float num84 = (float)color2.G / 270f;
								float num85 = (float)color2.B / 270f;
								float num86 = (float)(dust.color.R / byte.MaxValue);
								float num87 = (float)(dust.color.G / byte.MaxValue);
								float num88 = (float)(dust.color.B / byte.MaxValue);
								num83 *= dust.scale * 1.07f * num86;
								num84 *= dust.scale * 1.07f * num87;
								num85 *= dust.scale * 1.07f * num88;
								if (dust.alpha < 255)
								{
									dust5 = dust;
									dust5.scale += 0.09f;
									if (dust.scale >= 1f)
									{
										dust.scale = 1f;
										dust.alpha = 255;
									}
								}
								else
								{
									if ((double)dust.scale < 0.8)
									{
										dust5 = dust;
										dust5.scale -= 0.01f;
									}
									if ((double)dust.scale < 0.5)
									{
										dust5 = dust;
										dust5.scale -= 0.01f;
									}
								}
								if ((double)num83 < 0.05 && (double)num84 < 0.05 && (double)num85 < 0.05)
								{
									dust.active = false;
								}
								else
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num83, num84, num85);
								}
							}
							else if (dust.type == 15 || dust.type == 57 || dust.type == 58 || dust.type == 274)
							{
								Dust dust30 = dust;
								dust30.velocity.Y = dust30.velocity.Y * 0.98f;
								Dust dust31 = dust;
								dust31.velocity.X = dust31.velocity.X * 0.98f;
								float num89 = dust.scale;
								if (dust.type != 15)
								{
									num89 = dust.scale * 0.8f;
								}
								if (dust.noLight)
								{
									dust5 = dust;
									dust5.velocity *= 0.95f;
								}
								if (num89 > 1f)
								{
									num89 = 1f;
								}
								if (dust.type == 15)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num89 * 0.45f, num89 * 0.55f, num89);
								}
								else if (dust.type == 57)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num89 * 0.95f, num89 * 0.95f, num89 * 0.45f);
								}
								else if (dust.type == 58)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num89, num89 * 0.55f, num89 * 0.75f);
								}
							}
							else if (dust.type == 204)
							{
								if (dust.fadeIn > dust.scale)
								{
									dust5 = dust;
									dust5.scale += 0.02f;
								}
								else
								{
									dust5 = dust;
									dust5.scale -= 0.02f;
								}
								dust5 = dust;
								dust5.velocity *= 0.95f;
							}
							else if (dust.type == 110)
							{
								float num90 = dust.scale * 0.1f;
								if (num90 > 1f)
								{
									num90 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num90 * 0.2f, num90, num90 * 0.5f);
							}
							else if (dust.type == 111)
							{
								float num91 = dust.scale * 0.125f;
								if (num91 > 1f)
								{
									num91 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num91 * 0.2f, num91 * 0.7f, num91);
							}
							else if (dust.type == 112)
							{
								float num92 = dust.scale * 0.1f;
								if (num92 > 1f)
								{
									num92 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num92 * 0.8f, num92 * 0.2f, num92 * 0.8f);
							}
							else if (dust.type == 113)
							{
								float num93 = dust.scale * 0.1f;
								if (num93 > 1f)
								{
									num93 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num93 * 0.2f, num93 * 0.3f, num93 * 1.3f);
							}
							else if (dust.type == 114)
							{
								float num94 = dust.scale * 0.1f;
								if (num94 > 1f)
								{
									num94 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num94 * 1.2f, num94 * 0.5f, num94 * 0.4f);
							}
							else if (dust.type == 66)
							{
								if (dust.velocity.X < 0f)
								{
									dust5 = dust;
									dust5.rotation -= 1f;
								}
								else
								{
									dust5 = dust;
									dust5.rotation += 1f;
								}
								Dust dust32 = dust;
								dust32.velocity.Y = dust32.velocity.Y * 0.98f;
								Dust dust33 = dust;
								dust33.velocity.X = dust33.velocity.X * 0.98f;
								dust5 = dust;
								dust5.scale += 0.02f;
								float num95 = dust.scale;
								if (dust.type != 15)
								{
									num95 = dust.scale * 0.8f;
								}
								if (num95 > 1f)
								{
									num95 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num95 * ((float)dust.color.R / 255f), num95 * ((float)dust.color.G / 255f), num95 * ((float)dust.color.B / 255f));
							}
							else if (dust.type == 267)
							{
								if (dust.velocity.X < 0f)
								{
									dust5 = dust;
									dust5.rotation -= 1f;
								}
								else
								{
									dust5 = dust;
									dust5.rotation += 1f;
								}
								Dust dust34 = dust;
								dust34.velocity.Y = dust34.velocity.Y * 0.98f;
								Dust dust35 = dust;
								dust35.velocity.X = dust35.velocity.X * 0.98f;
								dust5 = dust;
								dust5.scale += 0.02f;
								float num96 = dust.scale * 0.8f;
								if (num96 > 1f)
								{
									num96 = 1f;
								}
								if (dust.noLight)
								{
									dust.noLight = false;
								}
								if (!dust.noLight)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num96 * ((float)dust.color.R / 255f), num96 * ((float)dust.color.G / 255f), num96 * ((float)dust.color.B / 255f));
								}
							}
							else if (dust.type == 20 || dust.type == 21 || dust.type == 231)
							{
								dust5 = dust;
								dust5.scale += 0.005f;
								Dust dust36 = dust;
								dust36.velocity.Y = dust36.velocity.Y * 0.94f;
								Dust dust37 = dust;
								dust37.velocity.X = dust37.velocity.X * 0.94f;
								float num97 = dust.scale * 0.8f;
								if (num97 > 1f)
								{
									num97 = 1f;
								}
								if (dust.type == 21)
								{
									num97 = dust.scale * 0.4f;
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num97 * 0.8f, num97 * 0.3f, num97);
								}
								else if (dust.type == 231)
								{
									num97 = dust.scale * 0.4f;
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num97, num97 * 0.5f, num97 * 0.3f);
								}
								else
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num97 * 0.3f, num97 * 0.6f, num97);
								}
							}
							else if (dust.type == 27 || dust.type == 45)
							{
								if (dust.type == 27 && dust.fadeIn >= 100f)
								{
									if ((double)dust.scale >= 1.5)
									{
										dust5 = dust;
										dust5.scale -= 0.01f;
									}
									else
									{
										dust5 = dust;
										dust5.scale -= 0.05f;
									}
									if ((double)dust.scale <= 0.5)
									{
										dust5 = dust;
										dust5.scale -= 0.05f;
									}
									if ((double)dust.scale <= 0.25)
									{
										dust5 = dust;
										dust5.scale -= 0.05f;
									}
								}
								dust5 = dust;
								dust5.velocity *= 0.94f;
								dust5 = dust;
								dust5.scale += 0.002f;
								float num98 = dust.scale;
								if (dust.noLight)
								{
									num98 *= 0.1f;
									dust5 = dust;
									dust5.scale -= 0.06f;
									if (dust.scale < 1f)
									{
										dust5 = dust;
										dust5.scale -= 0.06f;
									}
									if (Main.player[Main.myPlayer].wet)
									{
										dust5 = dust;
										dust5.position += Main.player[Main.myPlayer].velocity * 0.5f;
									}
									else
									{
										dust5 = dust;
										dust5.position += Main.player[Main.myPlayer].velocity;
									}
								}
								if (num98 > 1f)
								{
									num98 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num98 * 0.6f, num98 * 0.2f, num98);
							}
							else if (dust.type == 55 || dust.type == 56 || dust.type == 73 || dust.type == 74)
							{
								dust5 = dust;
								dust5.velocity *= 0.98f;
								float num99 = dust.scale * 0.8f;
								if (dust.type == 55)
								{
									if (num99 > 1f)
									{
										num99 = 1f;
									}
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num99, num99, num99 * 0.6f);
								}
								else if (dust.type == 73)
								{
									if (num99 > 1f)
									{
										num99 = 1f;
									}
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num99, num99 * 0.35f, num99 * 0.5f);
								}
								else if (dust.type == 74)
								{
									if (num99 > 1f)
									{
										num99 = 1f;
									}
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num99 * 0.35f, num99, num99 * 0.5f);
								}
								else
								{
									num99 = dust.scale * 1.2f;
									if (num99 > 1f)
									{
										num99 = 1f;
									}
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num99 * 0.35f, num99 * 0.5f, num99);
								}
							}
							else if (dust.type == 71 || dust.type == 72)
							{
								dust5 = dust;
								dust5.velocity *= 0.98f;
								float num100 = dust.scale;
								if (num100 > 1f)
								{
									num100 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num100 * 0.2f, 0f, num100 * 0.1f);
							}
							else if (dust.type == 76)
							{
								num3 = Main.snowDust;
								Main.snowDust = num3 + 1;
								dust5 = dust;
								dust5.scale += 0.009f;
								float y = Main.player[Main.myPlayer].velocity.Y;
								if (y > 0f && dust.fadeIn == 0f && dust.velocity.Y < y)
								{
									dust.velocity.Y = MathHelper.Lerp(dust.velocity.Y, y, 0.04f);
								}
								if (!dust.noLight && y > 0f)
								{
									Dust dust38 = dust;
									dust38.position.Y = dust38.position.Y + Main.player[Main.myPlayer].velocity.Y * 0.2f;
								}
								if (Collision.SolidCollision(dust.position - Vector2.One * 5f, 10, 10) && dust.fadeIn == 0f)
								{
									dust5 = dust;
									dust5.scale *= 0.9f;
									dust5 = dust;
									dust5.velocity *= 0.25f;
								}
							}
							else if (dust.type == 270)
							{
								dust5 = dust;
								dust5.velocity *= 1.00502515f;
								dust5 = dust;
								dust5.scale += 0.01f;
								dust.rotation = 0f;
								if (Collision.SolidCollision(dust.position - Vector2.One * 5f, 10, 10) && dust.fadeIn == 0f)
								{
									dust5 = dust;
									dust5.scale *= 0.95f;
									dust5 = dust;
									dust5.velocity *= 0.25f;
								}
								else
								{
									dust.velocity.Y = (float)Math.Sin((double)(dust.position.X * 0.00439822953f)) * 2f;
									Dust dust39 = dust;
									dust39.velocity.Y = dust39.velocity.Y - 3f;
									Dust dust40 = dust;
									dust40.velocity.Y = dust40.velocity.Y / 20f;
								}
							}
							else if (dust.type == 271)
							{
								dust5 = dust;
								dust5.velocity *= 1.00502515f;
								dust5 = dust;
								dust5.scale += 0.003f;
								dust.rotation = 0f;
								Dust dust41 = dust;
								dust41.velocity.Y = dust41.velocity.Y - 4f;
								Dust dust42 = dust;
								dust42.velocity.Y = dust42.velocity.Y / 6f;
							}
							else if (dust.type == 268)
							{
								num3 = Dust.SandStormCount;
								Dust.SandStormCount = num3 + 1;
								dust5 = dust;
								dust5.velocity *= 1.00502515f;
								dust5 = dust;
								dust5.scale += 0.01f;
								if (!flag)
								{
									dust5 = dust;
									dust5.scale -= 0.05f;
								}
								dust.rotation = 0f;
								float y2 = Main.player[Main.myPlayer].velocity.Y;
								if (y2 > 0f && dust.fadeIn == 0f && dust.velocity.Y < y2)
								{
									dust.velocity.Y = MathHelper.Lerp(dust.velocity.Y, y2, 0.04f);
								}
								if (!dust.noLight && y2 > 0f)
								{
									Dust dust43 = dust;
									dust43.position.Y = dust43.position.Y + y2 * 0.2f;
								}
								if (Collision.SolidCollision(dust.position - Vector2.One * 5f, 10, 10) && dust.fadeIn == 0f)
								{
									dust5 = dust;
									dust5.scale *= 0.9f;
									dust5 = dust;
									dust5.velocity *= 0.25f;
								}
								else
								{
									dust.velocity.Y = (float)Math.Sin((double)(dust.position.X * 0.00439822953f)) * 2f;
									Dust dust44 = dust;
									dust44.velocity.Y = dust44.velocity.Y + 3f;
								}
							}
							else if (!dust.noGravity && dust.type != 41 && dust.type != 44)
							{
								if (dust.type == 107)
								{
									dust5 = dust;
									dust5.velocity *= 0.9f;
								}
								else
								{
									Dust dust45 = dust;
									dust45.velocity.Y = dust45.velocity.Y + 0.1f;
								}
							}
							if (dust.type == 5 || (dust.type == 273 && dust.noGravity))
							{
								dust5 = dust;
								dust5.scale -= 0.04f;
							}
							if (dust.type == 33 || dust.type == 52 || dust.type == 266 || dust.type == 98 || dust.type == 99 || dust.type == 100 || dust.type == 101 || dust.type == 102 || dust.type == 103 || dust.type == 104 || dust.type == 105 || dust.type == 123)
							{
								if (dust.velocity.X == 0f)
								{
									if (Collision.SolidCollision(dust.position, 2, 2))
									{
										dust.scale = 0f;
									}
									dust5 = dust;
									dust5.rotation += 0.5f;
									dust5 = dust;
									dust5.scale -= 0.01f;
								}
								bool flag2 = Collision.WetCollision(new Vector2(dust.position.X, dust.position.Y), 4, 4);
								if (flag2)
								{
									dust5 = dust;
									dust5.alpha += 20;
									dust5 = dust;
									dust5.scale -= 0.1f;
								}
								dust5 = dust;
								dust5.alpha += 2;
								dust5 = dust;
								dust5.scale -= 0.005f;
								if (dust.alpha > 255)
								{
									dust.scale = 0f;
								}
								if (dust.velocity.Y > 4f)
								{
									dust.velocity.Y = 4f;
								}
								if (dust.noGravity)
								{
									if (dust.velocity.X < 0f)
									{
										dust5 = dust;
										dust5.rotation -= 0.2f;
									}
									else
									{
										dust5 = dust;
										dust5.rotation += 0.2f;
									}
									dust5 = dust;
									dust5.scale += 0.03f;
									Dust dust46 = dust;
									dust46.velocity.X = dust46.velocity.X * 1.05f;
									Dust dust47 = dust;
									dust47.velocity.Y = dust47.velocity.Y + 0.15f;
								}
							}
							if (dust.type == 35 && dust.noGravity)
							{
								dust5 = dust;
								dust5.scale += 0.03f;
								if (dust.scale < 1f)
								{
									Dust dust48 = dust;
									dust48.velocity.Y = dust48.velocity.Y + 0.075f;
								}
								Dust dust49 = dust;
								dust49.velocity.X = dust49.velocity.X * 1.08f;
								if (dust.velocity.X > 0f)
								{
									dust5 = dust;
									dust5.rotation += 0.01f;
								}
								else
								{
									dust5 = dust;
									dust5.rotation -= 0.01f;
								}
								float num101 = dust.scale * 0.6f;
								if (num101 > 1f)
								{
									num101 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f + 1f), num101, num101 * 0.3f, num101 * 0.1f);
							}
							else if (dust.type == 152 && dust.noGravity)
							{
								dust5 = dust;
								dust5.scale += 0.03f;
								if (dust.scale < 1f)
								{
									Dust dust50 = dust;
									dust50.velocity.Y = dust50.velocity.Y + 0.075f;
								}
								Dust dust51 = dust;
								dust51.velocity.X = dust51.velocity.X * 1.08f;
								if (dust.velocity.X > 0f)
								{
									dust5 = dust;
									dust5.rotation += 0.01f;
								}
								else
								{
									dust5 = dust;
									dust5.rotation -= 0.01f;
								}
							}
							else if (dust.type == 67 || dust.type == 92)
							{
								float num102 = dust.scale;
								if (num102 > 1f)
								{
									num102 = 1f;
								}
								if (dust.noLight)
								{
									num102 *= 0.1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), 0f, num102 * 0.8f, num102);
							}
							else if (dust.type == 185)
							{
								float num103 = dust.scale;
								if (num103 > 1f)
								{
									num103 = 1f;
								}
								if (dust.noLight)
								{
									num103 *= 0.1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num103 * 0.1f, num103 * 0.7f, num103);
							}
							else if (dust.type == 107)
							{
								float num104 = dust.scale * 0.5f;
								if (num104 > 1f)
								{
									num104 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num104 * 0.1f, num104, num104 * 0.4f);
							}
							else if (dust.type == 34 || dust.type == 35 || dust.type == 152)
							{
								if (!Collision.WetCollision(new Vector2(dust.position.X, dust.position.Y - 8f), 4, 4))
								{
									dust.scale = 0f;
								}
								else
								{
									dust5 = dust;
									dust5.alpha += Main.rand.Next(2);
									if (dust.alpha > 255)
									{
										dust.scale = 0f;
									}
									dust.velocity.Y = -0.5f;
									if (dust.type == 34)
									{
										dust5 = dust;
										dust5.scale += 0.005f;
									}
									else
									{
										dust5 = dust;
										Dust dust52 = dust5;
										num3 = dust5.alpha;
										dust52.alpha = num3 + 1;
										dust5 = dust;
										dust5.scale -= 0.01f;
										dust.velocity.Y = -0.2f;
									}
									Dust dust53 = dust;
									dust53.velocity.X = dust53.velocity.X + (float)Main.rand.Next(-10, 10) * 0.002f;
									if ((double)dust.velocity.X < -0.25)
									{
										dust.velocity.X = -0.25f;
									}
									if ((double)dust.velocity.X > 0.25)
									{
										dust.velocity.X = 0.25f;
									}
								}
								if (dust.type == 35)
								{
									float num105 = dust.scale * 0.3f + 0.4f;
									if (num105 > 1f)
									{
										num105 = 1f;
									}
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num105, num105 * 0.5f, num105 * 0.3f);
								}
							}
							if (dust.type == 68)
							{
								float num106 = dust.scale * 0.3f;
								if (num106 > 1f)
								{
									num106 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num106 * 0.1f, num106 * 0.2f, num106);
							}
							if (dust.type == 70)
							{
								float num107 = dust.scale * 0.3f;
								if (num107 > 1f)
								{
									num107 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num107 * 0.5f, 0f, num107);
							}
							if (dust.type == 41)
							{
								Dust dust54 = dust;
								dust54.velocity.X = dust54.velocity.X + (float)Main.rand.Next(-10, 11) * 0.01f;
								Dust dust55 = dust;
								dust55.velocity.Y = dust55.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.01f;
								if ((double)dust.velocity.X > 0.75)
								{
									dust.velocity.X = 0.75f;
								}
								if ((double)dust.velocity.X < -0.75)
								{
									dust.velocity.X = -0.75f;
								}
								if ((double)dust.velocity.Y > 0.75)
								{
									dust.velocity.Y = 0.75f;
								}
								if ((double)dust.velocity.Y < -0.75)
								{
									dust.velocity.Y = -0.75f;
								}
								dust5 = dust;
								dust5.scale += 0.007f;
								float num108 = dust.scale * 0.7f;
								if (num108 > 1f)
								{
									num108 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num108 * 0.4f, num108 * 0.9f, num108);
							}
							else if (dust.type == 44)
							{
								Dust dust56 = dust;
								dust56.velocity.X = dust56.velocity.X + (float)Main.rand.Next(-10, 11) * 0.003f;
								Dust dust57 = dust;
								dust57.velocity.Y = dust57.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.003f;
								if ((double)dust.velocity.X > 0.35)
								{
									dust.velocity.X = 0.35f;
								}
								if ((double)dust.velocity.X < -0.35)
								{
									dust.velocity.X = -0.35f;
								}
								if ((double)dust.velocity.Y > 0.35)
								{
									dust.velocity.Y = 0.35f;
								}
								if ((double)dust.velocity.Y < -0.35)
								{
									dust.velocity.Y = -0.35f;
								}
								dust5 = dust;
								dust5.scale += 0.0085f;
								float num109 = dust.scale * 0.7f;
								if (num109 > 1f)
								{
									num109 = 1f;
								}
								Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num109 * 0.7f, num109, num109 * 0.8f);
							}
							else if (dust2 == null || !dust2.MidUpdate(dust))
							{
								Dust dust58 = dust;
								dust58.velocity.X = dust58.velocity.X * 0.99f;
							}
							if (dust.type != 79 && dust.type != 268)
							{
								dust5 = dust;
								dust5.rotation += dust.velocity.X * 0.5f;
							}
							if (dust.fadeIn > 0f && dust.fadeIn < 100f)
							{
								if (dust.type == 235)
								{
									dust5 = dust;
									dust5.scale += 0.007f;
									int num110 = (int)dust.fadeIn - 1;
									if (num110 >= 0 && num110 <= 255)
									{
										Vector2 vector5 = dust.position - Main.player[num110].Center;
										float num111 = vector5.Length();
										num111 = 100f - num111;
										if (num111 > 0f)
										{
											dust5 = dust;
											dust5.scale -= num111 * 0.0015f;
										}
										vector5.Normalize();
										float num112 = (1f - dust.scale) * 20f;
										vector5 *= -num112;
										dust.velocity = (dust.velocity * 4f + vector5) / 5f;
									}
								}
								else if (dust.type == 46)
								{
									dust5 = dust;
									dust5.scale += 0.1f;
								}
								else if (dust.type == 213 || dust.type == 260)
								{
									dust5 = dust;
									dust5.scale += 0.1f;
								}
								else
								{
									dust5 = dust;
									dust5.scale += 0.03f;
								}
								if (dust.scale > dust.fadeIn)
								{
									dust.fadeIn = 0f;
								}
							}
							else if (dust.type == 213 || dust.type == 260)
							{
								dust5 = dust;
								dust5.scale -= 0.2f;
							}
							else
							{
								dust5 = dust;
								dust5.scale -= 0.01f;
							}
							if (dust.type >= 130 && dust.type <= 134)
							{
								float num113 = dust.scale;
								if (num113 > 1f)
								{
									num113 = 1f;
								}
								if (dust.type == 130)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num113 * 1f, num113 * 0.5f, num113 * 0.4f);
								}
								if (dust.type == 131)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num113 * 0.4f, num113 * 1f, num113 * 0.6f);
								}
								if (dust.type == 132)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num113 * 0.3f, num113 * 0.5f, num113 * 1f);
								}
								if (dust.type == 133)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num113 * 0.9f, num113 * 0.9f, num113 * 0.3f);
								}
								if (dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0.93f;
									if (dust.fadeIn == 0f)
									{
										dust5 = dust;
										dust5.scale += 0.0025f;
									}
								}
								else if (dust.type == 131)
								{
									dust5 = dust;
									dust5.velocity *= 0.98f;
									Dust dust59 = dust;
									dust59.velocity.Y = dust59.velocity.Y - 0.1f;
									dust5 = dust;
									dust5.scale += 0.0025f;
								}
								else
								{
									dust5 = dust;
									dust5.velocity *= 0.95f;
									dust5 = dust;
									dust5.scale -= 0.0025f;
								}
							}
							else if (dust.type >= 219 && dust.type <= 223)
							{
								float num114 = dust.scale;
								if (num114 > 1f)
								{
									num114 = 1f;
								}
								if (!dust.noLight)
								{
									if (dust.type == 219)
									{
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num114 * 1f, num114 * 0.5f, num114 * 0.4f);
									}
									if (dust.type == 220)
									{
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num114 * 0.4f, num114 * 1f, num114 * 0.6f);
									}
									if (dust.type == 221)
									{
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num114 * 0.3f, num114 * 0.5f, num114 * 1f);
									}
									if (dust.type == 222)
									{
										Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num114 * 0.9f, num114 * 0.9f, num114 * 0.3f);
									}
								}
								if (dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0.93f;
									if (dust.fadeIn == 0f)
									{
										dust5 = dust;
										dust5.scale += 0.0025f;
									}
								}
								dust5 = dust;
								dust5.velocity *= new Vector2(0.97f, 0.99f);
								dust5 = dust;
								dust5.scale -= 0.0025f;
								if (dust.customData != null && dust.customData is Player)
								{
									Player player6 = (Player)dust.customData;
									dust5 = dust;
									dust5.position += player6.position - player6.oldPosition;
								}
							}
							else if (dust.type == 226)
							{
								float num115 = dust.scale;
								if (num115 > 1f)
								{
									num115 = 1f;
								}
								if (!dust.noLight)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num115 * 0.2f, num115 * 0.7f, num115 * 1f);
								}
								if (dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0.93f;
									if (dust.fadeIn == 0f)
									{
										dust5 = dust;
										dust5.scale += 0.0025f;
									}
								}
								dust5 = dust;
								dust5.velocity *= new Vector2(0.97f, 0.99f);
								if (dust.customData != null && dust.customData is Player)
								{
									Player player7 = (Player)dust.customData;
									dust5 = dust;
									dust5.position += player7.position - player7.oldPosition;
								}
								dust5 = dust;
								dust5.scale -= 0.01f;
							}
							else if (dust.type == 272)
							{
								float num116 = dust.scale;
								if (num116 > 1f)
								{
									num116 = 1f;
								}
								if (!dust.noLight)
								{
									Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num116 * 0.5f, num116 * 0.2f, num116 * 0.8f);
								}
								if (dust.noGravity)
								{
									dust5 = dust;
									dust5.velocity *= 0.93f;
									if (dust.fadeIn == 0f)
									{
										dust5 = dust;
										dust5.scale += 0.0025f;
									}
								}
								dust5 = dust;
								dust5.velocity *= new Vector2(0.97f, 0.99f);
								if (dust.customData != null && dust.customData is Player)
								{
									Player player8 = (Player)dust.customData;
									dust5 = dust;
									dust5.position += player8.position - player8.oldPosition;
								}
								if (dust.customData != null && dust.customData is NPC)
								{
									NPC npc2 = (NPC)dust.customData;
									dust5 = dust;
									dust5.position += npc2.position - npc2.oldPosition;
								}
								dust5 = dust;
								dust5.scale -= 0.01f;
							}
							else if (dust.noGravity)
							{
								dust5 = dust;
								dust5.velocity *= 0.92f;
								if (dust.fadeIn == 0f)
								{
									dust5 = dust;
									dust5.scale -= 0.04f;
								}
							}
							if (dust.position.Y > Main.screenPosition.Y + (float)Main.screenHeight)
							{
								dust.active = false;
							}
							float num117 = 0.1f;
							if ((double)Dust.dCount == 0.5)
							{
								dust5 = dust;
								dust5.scale -= 0.001f;
							}
							if ((double)Dust.dCount == 0.6)
							{
								dust5 = dust;
								dust5.scale -= 0.0025f;
							}
							if ((double)Dust.dCount == 0.7)
							{
								dust5 = dust;
								dust5.scale -= 0.005f;
							}
							if ((double)Dust.dCount == 0.8)
							{
								dust5 = dust;
								dust5.scale -= 0.01f;
							}
							if ((double)Dust.dCount == 0.9)
							{
								dust5 = dust;
								dust5.scale -= 0.02f;
							}
							if ((double)Dust.dCount == 0.5)
							{
								num117 = 0.11f;
							}
							if ((double)Dust.dCount == 0.6)
							{
								num117 = 0.13f;
							}
							if ((double)Dust.dCount == 0.7)
							{
								num117 = 0.16f;
							}
							if ((double)Dust.dCount == 0.8)
							{
								num117 = 0.22f;
							}
							if ((double)Dust.dCount == 0.9)
							{
								num117 = 0.25f;
							}
							if (dust.scale < num117)
							{
								dust.active = false;
							}
							ModDust.TakeDownUpdateType(dust);
						}
					}
				}
				else
				{
					dust.active = false;
				}
				num3 = i;
			}
			int num118 = num;
			if ((double)num118 > (double)Main.maxDustToDraw * 0.9)
			{
				Dust.dCount = 0.9f;
				return;
			}
			if ((double)num118 > (double)Main.maxDustToDraw * 0.8)
			{
				Dust.dCount = 0.8f;
				return;
			}
			if ((double)num118 > (double)Main.maxDustToDraw * 0.7)
			{
				Dust.dCount = 0.7f;
				return;
			}
			if ((double)num118 > (double)Main.maxDustToDraw * 0.6)
			{
				Dust.dCount = 0.6f;
				return;
			}
			if ((double)num118 > (double)Main.maxDustToDraw * 0.5)
			{
				Dust.dCount = 0.5f;
				return;
			}
			Dust.dCount = 0f;
		}

		// Token: 0x060000C4 RID: 196 RVA: 0x000322F0 File Offset: 0x000304F0
		public Color GetAlpha(Color newColor)
		{
			ModDust dust = ModDust.GetDust(this.type);
			if (dust != null)
			{
				Color? color = dust.GetAlpha(this, newColor);
				if (color != null)
				{
					return color.Value;
				}
			}
			float num = (float)(255 - this.alpha) / 255f;
			if (this.type == 259)
			{
				return new Color(230, 230, 230, 230);
			}
			if (this.type == 261)
			{
				return new Color(230, 230, 230, 115);
			}
			if (this.type == 254 || this.type == 255)
			{
				return new Color(255, 255, 255, 0);
			}
			if (this.type == 258)
			{
				return new Color(150, 50, 50, 0);
			}
			if (this.type == 263 || this.type == 264)
			{
				return new Color((int)(this.color.R / 2 + 127), (int)(this.color.G + 127), (int)(this.color.B + 127), (int)(this.color.A / 8)) * 0.5f;
			}
			if (this.type == 235)
			{
				return new Color(255, 255, 255, 0);
			}
			if (((this.type >= 86 && this.type <= 91) || this.type == 262) && !this.noLight)
			{
				return new Color(255, 255, 255, 0);
			}
			if (this.type == 213 || this.type == 260)
			{
				int num2 = (int)(this.scale / 2.5f * 255f);
				return new Color(num2, num2, num2, num2);
			}
			if (this.type == 64 && this.alpha == 255 && this.noLight)
			{
				return new Color(255, 255, 255, 0);
			}
			if (this.type == 197)
			{
				return new Color(250, 250, 250, 150);
			}
			if (this.type >= 110 && this.type <= 114)
			{
				return new Color(200, 200, 200, 0);
			}
			if (this.type == 204)
			{
				return new Color(255, 255, 255, 0);
			}
			if (this.type == 181)
			{
				return new Color(200, 200, 200, 0);
			}
			if (this.type == 182 || this.type == 206)
			{
				return new Color(255, 255, 255, 0);
			}
			if (this.type == 159)
			{
				return new Color(250, 250, 250, 50);
			}
			if (this.type == 163 || this.type == 205)
			{
				return new Color(250, 250, 250, 0);
			}
			if (this.type == 170)
			{
				return new Color(200, 200, 200, 100);
			}
			if (this.type == 180)
			{
				return new Color(200, 200, 200, 0);
			}
			if (this.type == 175)
			{
				return new Color(200, 200, 200, 0);
			}
			if (this.type == 183)
			{
				return new Color(50, 0, 0, 0);
			}
			if (this.type == 172)
			{
				return new Color(250, 250, 250, 150);
			}
			if (this.type == 160 || this.type == 162 || this.type == 164 || this.type == 173)
			{
				int num3 = (int)(250f * this.scale);
				return new Color(num3, num3, num3, 0);
			}
			if (this.type == 92 || this.type == 106 || this.type == 107)
			{
				return new Color(255, 255, 255, 0);
			}
			if (this.type == 185)
			{
				return new Color(200, 200, 255, 125);
			}
			if (this.type == 127 || this.type == 187)
			{
				return new Color((int)newColor.R, (int)newColor.G, (int)newColor.B, 25);
			}
			if (this.type == 156 || this.type == 230 || this.type == 234)
			{
				return new Color(255, 255, 255, 0);
			}
			if (this.type == 270)
			{
				return new Color((int)(newColor.R / 2 + 127), (int)(newColor.G / 2 + 127), (int)(newColor.B / 2 + 127), 25);
			}
			if (this.type == 271)
			{
				return new Color((int)(newColor.R / 2 + 127), (int)(newColor.G / 2 + 127), (int)(newColor.B / 2 + 127), 127);
			}
			if (this.type == 6 || this.type == 242 || this.type == 174 || this.type == 135 || this.type == 75 || this.type == 20 || this.type == 21 || this.type == 231 || this.type == 169 || (this.type >= 130 && this.type <= 134) || this.type == 158)
			{
				return new Color((int)newColor.R, (int)newColor.G, (int)newColor.B, 25);
			}
			if (this.type >= 219 && this.type <= 223)
			{
				newColor = Color.Lerp(newColor, Color.White, 0.5f);
				return new Color((int)newColor.R, (int)newColor.G, (int)newColor.B, 25);
			}
			if (this.type == 226 || this.type == 272)
			{
				newColor = Color.Lerp(newColor, Color.White, 0.8f);
				return new Color((int)newColor.R, (int)newColor.G, (int)newColor.B, 25);
			}
			if (this.type == 228)
			{
				newColor = Color.Lerp(newColor, Color.White, 0.8f);
				return new Color((int)newColor.R, (int)newColor.G, (int)newColor.B, 25);
			}
			if (this.type == 229 || this.type == 269)
			{
				newColor = Color.Lerp(newColor, Color.White, 0.6f);
				return new Color((int)newColor.R, (int)newColor.G, (int)newColor.B, 25);
			}
			if ((this.type == 68 || this.type == 70) && this.noGravity)
			{
				return new Color(255, 255, 255, 0);
			}
			int num6;
			int num5;
			int num4;
			if (this.type == 157)
			{
				num4 = (num5 = (num6 = 255));
				float num7 = (float)Main.mouseTextColor / 100f - 1.6f;
				num4 = (int)((float)num4 * num7);
				num5 = (int)((float)num5 * num7);
				num6 = (int)((float)num6 * num7);
				int a = (int)(100f * num7);
				num4 += 50;
				if (num4 > 255)
				{
					num4 = 255;
				}
				num5 += 50;
				if (num5 > 255)
				{
					num5 = 255;
				}
				num6 += 50;
				if (num6 > 255)
				{
					num6 = 255;
				}
				return new Color(num4, num5, num6, a);
			}
			if (this.type == 15 || this.type == 274 || this.type == 20 || this.type == 21 || this.type == 29 || this.type == 35 || this.type == 41 || this.type == 44 || this.type == 27 || this.type == 45 || this.type == 55 || this.type == 56 || this.type == 57 || this.type == 58 || this.type == 73 || this.type == 74)
			{
				num = (num + 3f) / 4f;
			}
			else if (this.type == 43)
			{
				num = (num + 9f) / 10f;
			}
			else
			{
				if (this.type >= 244 && this.type <= 247)
				{
					return new Color(255, 255, 255, 0);
				}
				if (this.type == 66)
				{
					return new Color((int)newColor.R, (int)newColor.G, (int)newColor.B, 0);
				}
				if (this.type == 267)
				{
					return new Color((int)this.color.R, (int)this.color.G, (int)this.color.B, 0);
				}
				if (this.type == 71)
				{
					return new Color(200, 200, 200, 0);
				}
				if (this.type == 72)
				{
					return new Color(200, 200, 200, 200);
				}
			}
			num4 = (int)((float)newColor.R * num);
			num5 = (int)((float)newColor.G * num);
			num6 = (int)((float)newColor.B * num);
			int num8 = (int)newColor.A - this.alpha;
			if (num8 < 0)
			{
				num8 = 0;
			}
			if (num8 > 255)
			{
				num8 = 255;
			}
			return new Color(num4, num5, num6, num8);
		}

		// Token: 0x060000C5 RID: 197 RVA: 0x00032CF0 File Offset: 0x00030EF0
		public Color GetColor(Color newColor)
		{
			int num = (int)(this.color.R - (byte.MaxValue - newColor.R));
			int num2 = (int)(this.color.G - (byte.MaxValue - newColor.G));
			int num3 = (int)(this.color.B - (byte.MaxValue - newColor.B));
			int num4 = (int)(this.color.A - (byte.MaxValue - newColor.A));
			if (num < 0)
			{
				num = 0;
			}
			if (num > 255)
			{
				num = 255;
			}
			if (num2 < 0)
			{
				num2 = 0;
			}
			if (num2 > 255)
			{
				num2 = 255;
			}
			if (num3 < 0)
			{
				num3 = 0;
			}
			if (num3 > 255)
			{
				num3 = 255;
			}
			if (num4 < 0)
			{
				num4 = 0;
			}
			if (num4 > 255)
			{
				num4 = 255;
			}
			return new Color(num, num2, num3, num4);
		}

		// Token: 0x04000079 RID: 121
		public static float dCount;

		// Token: 0x0400007A RID: 122
		public static int lavaBubbles;

		// Token: 0x0400007B RID: 123
		public static int SandStormCount;

		// Token: 0x0400007C RID: 124
		public int dustIndex;

		// Token: 0x0400007D RID: 125
		public Vector2 position;

		// Token: 0x0400007E RID: 126
		public Vector2 velocity;

		// Token: 0x0400007F RID: 127
		public float fadeIn;

		// Token: 0x04000080 RID: 128
		public bool noGravity;

		// Token: 0x04000081 RID: 129
		public float scale;

		// Token: 0x04000082 RID: 130
		public float rotation;

		// Token: 0x04000083 RID: 131
		public bool noLight;

		// Token: 0x04000084 RID: 132
		public bool active;

		// Token: 0x04000085 RID: 133
		public int type;

		// Token: 0x04000086 RID: 134
		public Color color;

		// Token: 0x04000087 RID: 135
		public int alpha;

		// Token: 0x04000088 RID: 136
		public Rectangle frame;

		// Token: 0x04000089 RID: 137
		public ArmorShaderData shader;

		// Token: 0x0400008A RID: 138
		public object customData;

		// Token: 0x0400008B RID: 139
		public bool firstFrame;

		// Token: 0x0400008C RID: 140
		internal int realType = -1;
	}
}
